package com.ghsc.ghxc.jsb.view

import android.app.Activity
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.ghsc.ghxc.jsb.R
import com.scwang.smart.refresh.layout.SmartRefreshLayout

/**
 * 创建人 @author： xiaolin
 * 描述 ：Todo...
 */
class NotDataView {
    companion object {
        fun notDataView(activity: Activity, recyclerView: RecyclerView, refreshLayout: SmartRefreshLayout?): View? {
            val notDataView: View
            notDataView = activity.layoutInflater.inflate(R.layout.show_empty_view, recyclerView.parent as ViewGroup, false)
            val tvTitle = notDataView.findViewById<TextView>(R.id.tv_net_error)
            tvTitle.text = "暂无数据"
            notDataView.setOnClickListener { refreshLayout?.autoRefresh() }
            return notDataView
        }

        fun notDataView(activity: Activity, recyclerView: RecyclerView, refreshLayout: SmartRefreshLayout?, msg: String?): View? {
            val notDataView: View
            notDataView = activity.layoutInflater.inflate(R.layout.show_empty_view, recyclerView.parent as ViewGroup, false)
            val tvTitle = notDataView.findViewById<TextView>(R.id.tv_net_error)
            tvTitle.text = msg
            tvTitle.visibility = View.VISIBLE
            notDataView.setOnClickListener { refreshLayout?.autoRefresh() }
            return notDataView
        }

        fun notDataView(activity: Activity, recyclerView: RecyclerView, refreshLayout: SmartRefreshLayout?, msg: String?, imgID: Int): View? {
            val notDataView: View
            notDataView = activity.layoutInflater.inflate(R.layout.show_empty_view, recyclerView.parent as ViewGroup, false)
            val tvTitle = notDataView.findViewById<TextView>(R.id.tv_net_error)
            val img = notDataView.findViewById<ImageView>(R.id.img_error)
            img.setImageResource(imgID)
            tvTitle.text = msg
            tvTitle.visibility = View.VISIBLE
            notDataView.setOnClickListener { refreshLayout?.autoRefresh() }
            return notDataView
        }

        fun notDataView(activity: Activity, recyclerView: RecyclerView): View? {
            val notDataView: View
            notDataView = activity.layoutInflater.inflate(R.layout.show_empty_view, recyclerView.parent as ViewGroup, false)
            val tvTitle = notDataView.findViewById<TextView>(R.id.tv_net_error)
            tvTitle.text = "暂无数据"
            return notDataView
        }
    }
}